<template>
  <div class="page-container">
    <div class="components">
      <p class="components-title">树形控件</p>
      <el-input v-model="filterText" placeholder="Filter keyword" style="margin-bottom:30px;" />
      <el-tree
        ref="tree2"
        :data="data2"
        :props="defaultProps"
        :filter-node-method="filterNode"
        class="filter-tree"
        default-expand-all
      />
    </div>

    <div class="components">
      <p class="components-title">分页组件</p>
      <el-pagination
        background
        layout="sizes, prev, pager, next"
        :current-page="5"
        :total="1000"
      />
    </div>

    <div class="components">
      <p class="components-title">tab标签</p>
      <el-tabs v-model="activeName">
        <el-tab-pane label="用户管理" name="first">用户管理</el-tab-pane>
        <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
        <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
        <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>
      </el-tabs>
    </div>

    <div class="components">
      <p class="components-title">步骤进度</p>
      <el-steps :active="1">
        <el-step title="步骤 1" description="这是一段很长很长很长的描述性文字" />
        <el-step title="步骤 2" description="这是一段很长很长很长的描述性文字" />
        <el-step title="步骤 3" description="这段就没那么长了" />
      </el-steps>
    </div>

    <div class="components">
      <p class="components-title">富文本</p>
      <RichText
        :value.sync="detail"
      />
    </div>

    <div class="components">
      <p class="components-title">上传组件</p>
      <div class="upload-box">
        <UploadFile :extra-data="extraData" :img-list="imgList" @change="uploadHandle">
          <div slot="tip" class="upload-tip">只能上传jpg/png文件，且不超过5000kb</div>
        </UploadFile>
      </div>

    </div>
  </div>
</template>

<script>
import RichText from '@/components/RichText/index.vue'
import UploadFile from '@/components/UploadFile/index.vue'
export default {
  components: {
    RichText,
    UploadFile
  },
  data() {
    return {
      activeName: 'second',
      filterText: '',
      data2: [{
        id: 1,
        label: 'Level one 1',
        children: [{
          id: 4,
          label: 'Level two 1-1',
          children: [{
            id: 9,
            label: 'Level three 1-1-1'
          }, {
            id: 10,
            label: 'Level three 1-1-2'
          }]
        }]
      }, {
        id: 2,
        label: 'Level one 2',
        children: [{
          id: 5,
          label: 'Level two 2-1'
        }, {
          id: 6,
          label: 'Level two 2-2'
        }]
      }, {
        id: 3,
        label: 'Level one 3',
        children: [{
          id: 7,
          label: 'Level two 3-1'
        }, {
          id: 8,
          label: 'Level two 3-2'
        }]
      }],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      detail: '<h2>I am Example</h2>',
      extraData: {
        isPublic: true,
        indexName: 'customer',
        waterMarkType: 2
      },
      imgList: []
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree2.filter(val)
    }
  },

  methods: {
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },

    uploadHandle() {

    }
  }
}
</script>

<style scoped>
.components{
  margin-bottom: 50px;
}

.components-title{
  margin-bottom: 20px;
}
</style>

